<template>
  <div class="item viewpoint">
    <div class="item-h">
      <span class="line"></span>
      <b class="ftz16">Ta的观点</b>
      <a href="javascript: void(0)" @click.stop.prevent="linkToDashboard()" class="fr">更多></a>
    </div>
    <div class="con">
      <NoDataTips v-if="list.length === 0"/>
      <ul v-else>
        <li v-for="(item,index) in list" :key="index">
          <router-link :to="'/articleDetails/' + item.viewPointId">
          <label>{{index+1}}</label>
          <div class="txt fr">
            <p style="margin:0;cursor: pointer;" class="title" @click="changeArticle(item.id)">{{item.title}}</p>
            <p>
              <span>{{item.author}}</span>
              <span class="fr">{{item.createTime | parseTime('{m}-{d} {h}:{i}')}}</span>
            </p>
          </div>
          </router-link>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  props: ['authorId', 'list'],
  computed: {
    ...mapState({
      userInfo: state => state.me.sysUser || {}
    }),
    userId () {
      return this.$store.state.me.sysUser.userId
    }
  },
  data () {
    return {

    }
  },
  methods: {
    linkToDashboard () {
      if (this.userId === this.authorId) {
        if (this.userInfo.authType === '0') {
          this.$router.push('/dashboardUser/viewpoint')
        } else {
          this.$router.push('/dashboardAuth')
        }
      } else {
        this.$router.push('/dashboard/viewpoint/' + this.authorId)
      }
    },
    changeArticle (id) {
      this.$router.push({
        path: `/articleDetail/${id}/1`
      })
    }
  }
}
</script>

<style scoped lang="scss">
  .viewpoint .item-h{
    padding: 0 4%;
  }
  .viewpoint .con li{
    padding: 14px 6%;
    border-bottom: 1px solid #e6e6e6;
    overflow: auto;
  }
  .viewpoint .con li:last-child{
    border-bottom: 0;
  }
  .viewpoint .con li label{
    display: inline-block;
    width: 14px;
    height: 14px;
    background:#808080;
    border-radius: 2px;
    color: #fff;
    font-size: 12px;
    text-align: center;
    line-height: 14px;
  }
  .viewpoint .con li:first-child a label{
    background: #f23e3e;
  }
  .viewpoint .con li:nth-child(2) a label{
    background: #f23e3e;
  }
  .viewpoint .con li:nth-child(3) a label{
    background: #f23e3e;
  }
  .viewpoint .con .txt{
    width: 91%;
  }
  .viewpoint .con .txt .title{
    display: block;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .viewpoint .con .txt p{
    color: #808080;
    margin-top: 8px;
  }
</style>
